<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    // 产品表
    protected $table = 'product';
    protected $primaryKey = 'id';
    protected $dateFormat = 'U';
    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i',
        'updated_at' => 'datetime:Y-m-d H:i'
    ];

    public function banner(){
        return $this->hasMany('App\Model\ProductImage','product_id');
    }

    public function comment(){
        return $this->hasMany('App\Model\ProductComment','product_id');
    }

    public function getHomeProduct($param){
        $result = $this->where('category_id',9)
            ->limit(3)
            ->get();
        return $result;
    }
}
